<!DOCTYPE html>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>highlight.pony</title>
<meta name="generator" content="KF5::SyntaxHighlighting (Pony)"/>
</head><body style="color:#1f1c1b"><pre>
<span style="color:#898887;">// Test file for Pony syntax highlighting, released under MIT License</span>

<span style="font-weight:bold;">primitive</span> <span style="color:#0057ae;">Red</span>   <span style="font-weight:bold;">fun</span> <span style="color:#644a9b;">apply</span>(): <span style="color:#0057ae;">U32</span> =&gt; <span style="color:#b08000;">0xFFFF0000</span>

<span style="font-weight:bold;">primitive</span> <span style="color:#0057ae;">Colours</span>
  <span style="font-weight:bold;">fun</span> <span style="color:#644a9b;">black</span>(): <span style="color:#0057ae;">U32</span> =&gt; <span style="color:#b08000;">0xFF000000</span>
  <span style="font-weight:bold;">fun</span> <span style="color:#644a9b;">red</span>(): <span style="color:#0057ae;">U32</span> =&gt; <span style="color:#b08000;">0xFFFF0000</span>

<span style="font-weight:bold;">primitive</span> <span style="color:#0057ae;">Black</span>
<span style="font-weight:bold;">primitive</span> <span style="color:#0057ae;">Blue</span>

<span style="font-weight:bold;">type</span> <span style="color:#0057ae;">Colour</span> <span style="font-weight:bold;">is</span> (<span style="color:#0057ae;">Black</span> | <span style="color:#0057ae;">Blue</span> )

<span style="font-weight:bold;">primitive</span> <span style="color:#0057ae;">ColourList</span>
  <span style="font-weight:bold;">fun</span> <span style="color:#0057ae;font-style:italic;">tag</span> <span style="color:#644a9b;">apply</span>(): <span style="color:#0057ae;">Array</span>[<span style="color:#0057ae;">Colour</span>] =&gt;
    [<span style="color:#0057ae;">Black</span>; <span style="color:#0057ae;">Blue</span>]

<span style="font-weight:bold;">for</span> colour <span style="font-weight:bold;">in</span> <span style="color:#0057ae;">ColourList</span>().values() <span style="font-weight:bold;">do</span>
<span style="font-weight:bold;">end</span>

<span style="font-weight:bold;">type</span> <span style="color:#0057ae;">EGLEvent</span> <span style="font-weight:bold;">is</span> (<span style="color:#0057ae;">U8</span>, <span style="color:#0057ae;">F32</span>, <span style="color:#0057ae;">F32</span>)
(<span style="font-weight:bold;">var</span> code, <span style="font-weight:bold;">var</span> x, <span style="font-weight:bold;">var</span> y) = <span style="color:#644a9b;">@getEvent</span>[<span style="color:#0057ae;">EGLEvent</span>]()

<span style="font-weight:bold;">primitive</span> <span style="color:#0057ae;">_XDisplayHandle</span>
<span style="font-weight:bold;">primitive</span> <span style="color:#0057ae;">_EGLDisplayHandle</span>

<span style="font-weight:bold;">let</span> x_dpy = <span style="color:#644a9b;">@XOpenDisplay</span>[<span style="color:#0057ae;">Pointer</span>[<span style="color:#0057ae;">_XDisplayHandle</span>]](<span style="color:#0057ae;">U32</span>(<span style="color:#b08000;">0</span>))
<span style="font-weight:bold;">if</span> x_dpy.is_null() <span style="font-weight:bold;">then</span>
  env.out.print(<span style="color:#bf0303;">&quot;XOpenDisplay failed&quot;</span>)
<span style="font-weight:bold;">end</span>

<span style="font-weight:bold;">let</span> e_dpy = <span style="color:#644a9b;">@eglGetDisplay</span>[<span style="color:#0057ae;">Pointer</span>[<span style="color:#0057ae;">_EGLDisplayHandle</span>]](x_dpy)
<span style="font-weight:bold;">if</span> e_dpy.is_null() <span style="font-weight:bold;">then</span>
  env.out.print(<span style="color:#bf0303;">&quot;eglGetDisplay failed&quot;</span>)
<span style="font-weight:bold;">end</span>

<span style="font-weight:bold;">primitive</span> <span style="color:#0057ae;">_EGLConfigHandle</span>
<span style="font-weight:bold;">let</span> a = <span style="color:#0057ae;">Array</span>[<span style="color:#0057ae;">U16</span>](<span style="color:#b08000;">8</span>)
a.push(<span style="color:#b08000;">0x3040</span>)
a.push(<span style="color:#b08000;">0b01011</span>)
<span style="font-weight:bold;">let</span> config = <span style="color:#0057ae;">Pointer</span>[<span style="color:#0057ae;">_EGLConfigHandle</span>]
<span style="font-weight:bold;">if</span> <span style="color:#644a9b;">@eglChooseConfig</span>[<span style="color:#0057ae;">U32</span>](e_dpy, a, config, <span style="color:#0057ae;">U32</span>(<span style="color:#b08000;">1</span>), <span style="color:#0057ae;">Pointer</span>[<span style="color:#0057ae;">U32</span>]) == <span style="color:#b08000;">0</span> <span style="font-weight:bold;">then</span>
    env.out.print(<span style="color:#bf0303;">&quot;eglChooseConfig failed&quot;</span>)
<span style="font-weight:bold;">end</span>


<span style="font-weight:bold;">actor</span> <span style="color:#0057ae;">Main</span>
  <span style="font-weight:bold;">new</span> <span style="color:#644a9b;">create</span>(env: <span style="color:#0057ae;">Env</span>) =&gt;
    <span style="color:#898887;">// The no of arguments</span>
    env.out.print(env.args.size().string())
    <span style="font-weight:bold;">for</span> value <span style="font-weight:bold;">in</span> env.args.values() <span style="font-weight:bold;">do</span>
      env.out.print(value)
    <span style="font-weight:bold;">end</span>
    <span style="color:#898887;">// Access the arguments the first one will always be the the appication name</span>
    <span style="font-weight:bold;">try</span> env.out.print(env.args(<span style="color:#b08000;">0</span>)?) <span style="font-weight:bold;">end</span>

<span style="font-weight:bold;">actor</span> <span style="color:#0057ae;">Main</span>
  <span style="font-weight:bold;">new</span> <span style="color:#644a9b;">create</span>(env: <span style="color:#0057ae;">Env</span>) =&gt;
    <span style="font-weight:bold;">var</span> options = <span style="color:#0057ae;">Options</span>(env)

    options
      .add(<span style="color:#bf0303;">&quot;output&quot;</span>, <span style="color:#bf0303;">&quot;o&quot;</span>, <span style="color:#0057ae;">StringArgument</span>)

    env.out.print(options.has_argument())

    <span style="font-weight:bold;">for</span> option <span style="font-weight:bold;">in</span> options <span style="font-weight:bold;">do</span>
      <span style="font-weight:bold;">match</span> option
      | (<span style="color:#bf0303;">&quot;output&quot;</span>, <span style="font-weight:bold;">var</span> arg: <span style="color:#0057ae;">String</span>) =&gt; _outputFileName = arg.string()
      | <span style="font-weight:bold;">let</span> err: <span style="color:#0057ae;">ParseError</span> =&gt;
          err.report(env.out)
          env.out.print(
            <span style="color:#bf0303;">&quot;&quot;&quot;</span>
<span style="color:#bf0303;">            pony-embed [OPTIONS]</span>
<span style="color:#bf0303;">              --output     name   string output filename.</span>
<span style="color:#bf0303;">            &quot;&quot;&quot;</span>
          )
      <span style="font-weight:bold;">end</span>
    <span style="font-weight:bold;">end</span>

<span style="font-weight:bold;">use</span> <span style="color:#bf0303;">&quot;ponytest&quot;</span>

<span style="font-weight:bold;">actor</span> <span style="color:#0057ae;">Main</span> <span style="font-weight:bold;">is</span> <span style="color:#0057ae;">TestList</span>
  <span style="font-weight:bold;">new</span> <span style="color:#644a9b;">create</span>(env: <span style="color:#0057ae;">Env</span>) =&gt; <span style="color:#0057ae;">PonyTest</span>(env, <span style="font-weight:bold;">this</span>)
  <span style="font-weight:bold;">new</span> <span style="color:#644a9b;">make</span>() =&gt; <span style="color:#0057ae;">None</span>

  <span style="font-weight:bold;">fun</span> <span style="color:#0057ae;font-style:italic;">tag</span> <span style="color:#644a9b;">tests</span>(test: <span style="color:#0057ae;">PonyTest</span>) =&gt;
    test(<span style="color:#0057ae;">_TestAddition</span>)

<span style="font-weight:bold;">class</span> <span style="color:#0057ae;font-style:italic;">iso</span> <span style="color:#0057ae;">_TestAddition</span> <span style="font-weight:bold;">is</span> <span style="color:#0057ae;">UnitTest</span>
  <span style="color:#bf0303;">&quot;&quot;&quot;</span>
<span style="color:#bf0303;">  Adding 2 numbers</span>
<span style="color:#bf0303;">  &quot;&quot;&quot;</span>
  <span style="font-weight:bold;">fun</span> <span style="color:#644a9b;">name</span>(): <span style="color:#0057ae;">String</span> =&gt; <span style="color:#bf0303;">&quot;u32/add&quot;</span>

  <span style="font-weight:bold;">fun</span> <span style="color:#644a9b;">apply</span>(h: <span style="color:#0057ae;">TestHelper</span>): <span style="color:#0057ae;">TestResult</span> =&gt;
    h.expect_eq[<span style="color:#0057ae;">U32</span>](<span style="color:#b08000;">2</span> + <span style="color:#b08000;">2</span>, <span style="color:#b08000;">4</span>)

<span style="font-weight:bold;">fun</span> <span style="color:#0057ae;font-style:italic;">tag</span> <span style="color:#644a9b;">log</span>(msg: <span style="color:#0057ae;">String</span>, verbose: <span style="color:#0057ae;">Bool</span> = <span style="font-weight:bold;">false</span>)
<span style="font-weight:bold;">be</span> <span style="color:#644a9b;">fail</span>() =&gt;
<span style="font-weight:bold;">be</span> <span style="color:#644a9b;">assert_failed</span>(msg: <span style="color:#0057ae;">String</span>) =&gt;
<span style="font-weight:bold;">fun</span> <span style="color:#0057ae;font-style:italic;">tag</span> <span style="color:#644a9b;">assert_true</span>(actual: <span style="color:#0057ae;">Bool</span>, msg: <span style="color:#0057ae;">String</span> = <span style="color:#bf0303;">&quot;&quot;</span>) ?
<span style="font-weight:bold;">fun</span> <span style="color:#0057ae;font-style:italic;">tag</span> <span style="color:#644a9b;">expect_true</span>(actual: <span style="color:#0057ae;">Bool</span>, msg: <span style="color:#0057ae;">String</span> = <span style="color:#bf0303;">&quot;&quot;</span>): <span style="color:#0057ae;">Bool</span>
<span style="font-weight:bold;">fun</span> <span style="color:#0057ae;font-style:italic;">tag</span> <span style="color:#644a9b;">expect_eq</span>[<span style="color:#0057ae;">A</span>: (<span style="color:#0057ae;">Equatable</span>[<span style="color:#0057ae;">A</span>] <span style="color:#0057ae;">#read</span> &amp; <span style="color:#0057ae;">Stringable</span>)]
  (expect: <span style="color:#0057ae;">A</span>, actual: <span style="color:#0057ae;">A</span>, msg: <span style="color:#0057ae;">String</span> = <span style="color:#bf0303;">&quot;&quot;</span>): <span style="color:#0057ae;">Bool</span>
<span style="font-weight:bold;">fun</span> <span style="color:#0057ae;font-style:italic;">tag</span> <span style="color:#644a9b;">expect_eq</span>[<span style="color:#0057ae;">A</span>: (<span style="color:#0057ae;">Equatable</span>[<span style="color:#0057ae;">A</span>] <span style="color:#bf0303;text-decoration:underline;">#unknown</span> &amp; <span style="color:#0057ae;">Stringable</span>)]
  (expect: <span style="color:#0057ae;">A</span>, actual: <span style="color:#0057ae;">A</span>, msg: <span style="color:#0057ae;">String</span> = <span style="color:#bf0303;">&quot;&quot;</span>): <span style="color:#0057ae;">Bool</span>

<span style="font-weight:bold;">fun</span> <span style="color:#644a9b;">add</span>(other: <span style="color:#0057ae;">A</span>): <span style="color:#0057ae;">A</span>
<span style="font-weight:bold;">fun</span> <span style="color:#644a9b;">sub</span>(other: <span style="color:#0057ae;">A</span>): <span style="color:#0057ae;">A</span>
<span style="font-weight:bold;">fun</span> <span style="color:#644a9b;">mul</span>(other: <span style="color:#0057ae;">A</span>): <span style="color:#0057ae;">A</span>
<span style="font-weight:bold;">fun</span> <span style="color:#644a9b;">div</span>(other: <span style="color:#0057ae;">A</span>): <span style="color:#0057ae;">A</span>
<span style="font-weight:bold;">fun</span> <span style="color:#644a9b;">mod</span>(other: <span style="color:#0057ae;">A</span>): <span style="color:#0057ae;">A</span>
<span style="font-weight:bold;">fun</span> <span style="color:#644a9b;">eq</span>(other: <span style="color:#0057ae;">A</span>): <span style="color:#0057ae;">Bool</span>
<span style="font-weight:bold;">fun</span> <span style="color:#644a9b;">ne</span>(other: <span style="color:#0057ae;">A</span>): <span style="color:#0057ae;">Bool</span>
<span style="font-weight:bold;">fun</span> <span style="color:#644a9b;">lt</span>(other: <span style="color:#0057ae;">A</span>): <span style="color:#0057ae;">Bool</span>
<span style="font-weight:bold;">fun</span> <span style="color:#644a9b;">le</span>(other: <span style="color:#0057ae;">A</span>): <span style="color:#0057ae;">Bool</span>
<span style="font-weight:bold;">fun</span> <span style="color:#644a9b;">ge</span>(other: <span style="color:#0057ae;">A</span>): <span style="color:#0057ae;">Bool</span>
<span style="font-weight:bold;">fun</span> <span style="color:#644a9b;">gt</span>(other: <span style="color:#0057ae;">A</span>): <span style="color:#0057ae;">Bool</span>
<span style="font-weight:bold;">fun</span> <span style="color:#644a9b;">shl</span>(other: <span style="color:#0057ae;">A</span>): <span style="color:#0057ae;">A</span>
<span style="font-weight:bold;">fun</span> <span style="color:#644a9b;">shr</span>(other: <span style="color:#0057ae;">A</span>): <span style="color:#0057ae;">A</span>
<span style="font-weight:bold;">fun</span> <span style="color:#644a9b;">op_and</span>(other:<span style="color:#0057ae;">A</span>): <span style="color:#0057ae;">A</span>
<span style="font-weight:bold;">fun</span> <span style="color:#644a9b;">op_or</span>(other: <span style="color:#0057ae;">A</span>): <span style="color:#0057ae;">A</span>
<span style="font-weight:bold;">fun</span> <span style="color:#644a9b;">op_xor</span>(othr: <span style="color:#0057ae;">A</span>): <span style="color:#0057ae;">A</span>

<span style="font-weight:bold;">class</span> <span style="color:#0057ae;">Test</span>
  <span style="font-weight:bold;">fun</span> <span style="color:#644a9b;">alpha</span>() =&gt;
    <span style="color:#bf0303;">&quot;&quot;&quot;</span>
<span style="color:#bf0303;">    &quot;&quot;&quot;</span>

<span style="font-weight:bold;">let</span> dice: <span style="color:#0057ae;">Array</span>[<span style="color:#0057ae;">U32</span>] = [<span style="color:#b08000;">1</span>; <span style="color:#b08000;">2</span>; <span style="color:#b08000;">3</span>
  <span style="color:#b08000;">4</span>
  <span style="color:#b08000;">5</span>
  <span style="color:#b08000;">6</span>
]

<span style="font-weight:bold;">actor</span> <span style="color:#0057ae;">Main</span>
  <span style="font-weight:bold;">fun</span> <span style="color:#644a9b;">foo</span>(n:<span style="color:#0057ae;">U32</span>): {<span style="color:#0057ae;font-style:italic;">ref</span>(<span style="color:#0057ae;">U32</span>): <span style="color:#0057ae;">U32</span>} =&gt;
    <span style="font-weight:bold;">var</span> s: <span style="color:#0057ae;">Array</span>[<span style="color:#0057ae;">U32</span>] = <span style="color:#0057ae;">Array</span>[<span style="color:#0057ae;">U32</span>].init(n, <span style="color:#b08000;">1</span>)
    {<span style="color:#0057ae;font-style:italic;">ref</span>(i:<span style="color:#0057ae;">U32</span>)(s): <span style="color:#0057ae;">U32</span> =&gt;
      <span style="font-weight:bold;">try</span>
        s(<span style="color:#b08000;">0</span>) = s(<span style="color:#b08000;">0</span>) + i
        s(<span style="color:#b08000;">0</span>)
      <span style="font-weight:bold;">else</span>
        <span style="color:#b08000;">0</span>
      <span style="font-weight:bold;">end</span>
    }

  <span style="font-weight:bold;">new</span> <span style="color:#644a9b;">create</span>(env:<span style="color:#0057ae;">Env</span>) =&gt;
    <span style="font-weight:bold;">var</span> f = foo(<span style="color:#b08000;">5</span>)
    env.out.print(f(<span style="color:#b08000;">10</span>).string())
    env.out.print(f(<span style="color:#b08000;">20</span>).string())

<span style="color:#898887;">/* nested /* commentary */ */</span>
<span style="color:#898887;">// single comment</span>

<span style="font-weight:bold;">class</span> <span style="color:#0057ae;">A</span>
<span style="font-weight:bold;">class</span> <span style="color:#0057ae;">_A</span>
x'
x''
x'.string()
<span style="color:#3daee9;">'\uaaaa'</span>
<span style="color:#3daee9;">'\Ubbbbbb'</span>
<span style="color:#3daee9;">'\xcc'</span>
<span style="color:#3daee9;">'\''</span>
<span style="color:#3daee9;">'\n'</span>
<span style="color:#bf0303;">&quot;</span><span style="color:#3daee9;">\uaaaa</span><span style="color:#bf0303;">a&quot;</span>
<span style="color:#bf0303;">&quot;</span><span style="color:#3daee9;">\Ubbbbbb</span><span style="color:#bf0303;">b&quot;</span>
<span style="color:#bf0303;">&quot;</span><span style="color:#3daee9;">\xcc</span><span style="color:#bf0303;">c&quot;</span>
<span style="color:#bf0303;">&quot;</span><span style="color:#3daee9;">\&quot;</span><span style="color:#bf0303;">&quot;</span>
<span style="color:#bf0303;">&quot;</span><span style="color:#3daee9;">\n</span><span style="color:#bf0303;">&quot;</span>
<span style="color:#b08000;">34.4</span>
<span style="color:#b08000;">34.4e43</span>
<span style="color:#b08000;">43e4</span>
<span style="color:#b08000;">0x3040</span>
<span style="color:#b08000;">0xaF</span>
<span style="color:#b08000;">0b01</span>
<span style="color:#b08000;">3_43_4</span>
<span style="color:#b08000;">0x0_4</span>

<span style="font-weight:bold;">fun</span> <span style="color:#644a9b;">create</span>(): <span style="color:#0057ae;">U32</span> =&gt; <span style="color:#b08000;">0</span>
<span style="font-weight:bold;">fun</span> <span style="color:#0057ae;font-style:italic;">iso</span> <span style="color:#644a9b;">create</span>(): <span style="color:#0057ae;">U32</span> =&gt; <span style="color:#b08000;">0</span>
<span style="font-weight:bold;">fun</span> <span style="color:#0057ae;">\\ abc \\</span>  <span style="color:#0057ae;font-style:italic;">iso</span> <span style="color:#644a9b;">create</span>(): <span style="color:#0057ae;">U32</span> =&gt; <span style="color:#b08000;">0</span>
<span style="font-weight:bold;">class</span> <span style="color:#0057ae;">\\ packet, blah \\</span> <span style="color:#0057ae;font-style:italic;">iso</span> <span style="color:#0057ae;">Xyz</span>
<span style="font-weight:bold;">if</span> <span style="color:#0057ae;">\\ likely \\</span> a <span style="font-weight:bold;">then</span>
<span style="font-weight:bold;">end</span>

a.endnormal

print();print()

<span style="color:#898887;">/* syntactically false: */</span>

<span style="font-weight:bold;">class</span> <span style="color:#bf0303;text-decoration:underline;">_aA</span>
<span style="font-weight:bold;">class</span> <span style="color:#bf0303;text-decoration:underline;">_a</span>
<span style="font-weight:bold;">class</span> <span style="color:#bf0303;text-decoration:underline;">a</span>
<span style="color:#bf0303;text-decoration:underline;">0b2332</span>
<span style="color:#bf0303;text-decoration:underline;">0b</span>
<span style="color:#bf0303;text-decoration:underline;">0x</span>
<span style="color:#bf0303;text-decoration:underline;">0xgf</span>
<span style="color:#bf0303;text-decoration:underline;">0f00</span>
<span style="color:#bf0303;text-decoration:underline;">3.</span>
<span style="color:#bf0303;text-decoration:underline;">.3</span>
<span style="color:#bf0303;text-decoration:underline;">3.</span>e3
<span style="color:#bf0303;text-decoration:underline;">3_</span>
<span style="color:#bf0303;text-decoration:underline;">3__43_4</span>
<span style="color:#bf0303;text-decoration:underline;">''</span>
<span style="color:#bf0303;text-decoration:underline;">'</span>\u'
<span style="color:#bf0303;text-decoration:underline;">'</span>\ua'
<span style="color:#bf0303;text-decoration:underline;">'</span>\uaaa'
<span style="color:#bf0303;text-decoration:underline;">'</span>\uaaaaa'
<span style="color:#bf0303;text-decoration:underline;">'</span>\uyyyy'
<span style="color:#bf0303;">&quot;</span><span style="color:#bf0303;text-decoration:underline;">\u</span><span style="color:#bf0303;">&quot;</span>
<span style="color:#bf0303;">&quot;</span><span style="color:#bf0303;text-decoration:underline;">\u</span><span style="color:#bf0303;">a&quot;</span>
<span style="color:#bf0303;">&quot;</span><span style="color:#bf0303;text-decoration:underline;">\u</span><span style="color:#bf0303;">aaa&quot;</span>
<span style="color:#bf0303;">&quot;</span><span style="color:#bf0303;text-decoration:underline;">\u</span><span style="color:#bf0303;">yyyy&quot;</span>
a<span style="color:#bf0303;text-decoration:underline;">'</span>a

<span style="font-weight:bold;">class</span> <span style="color:#bf0303;text-decoration:underline;">badType</span>
print()<span style="color:#bf0303;text-decoration:underline;">;</span>
</pre></body></html>
